package cn.line5.seam.cms.article;

import java.util.List;

import cn.line5.seam.annotations.In;
import cn.line5.seam.annotations.Name;
import cn.line5.seam.annotations.Out;
import cn.line5.seam.annotations.Parameter;
import cn.line5.seam.db.PageResult;

@Name("articleRemote")
/**
 * <h1>LSEAM框架示例组件调用类</h1>
 * <br/>
 * 
 * @author Liu,yandong
 */
public class ArticleRemote {

	@In("articleService")
	// 注入业务层接口
	private ArticleService articleService;

	@Parameter
	// 参数
	private String id;

	@Parameter
	// 参数
	private String currentPage;

	@Parameter
	// 参数
	private ArticleVo vo;

	@Parameter
	// 参数
	private String[] deleteId;

	@Out
	// 输出
	private String returnMessage;

	@Out
	// 输出
	private List<ArticleVo> list;

	@Out
	// 输出
	private ArticleVo returnVo;

	@Out
	// 输出
	private PageResult<ArticleVo> pageResult;

	// 列表
	public void listArticle() {
		list = this.articleService.getList();
	}

	// 分页列表
	public void listPageArticle() {
		pageResult = this.articleService.getPageList(currentPage);
	}

	// 获取单个
	public void getArticle() {
		returnVo = this.articleService.getArticle(id);
	}

	// 在线报名
	public void signUpArticle() {
		returnVo = this.articleService.getArticleVo(vo);
		if(returnVo == null || returnVo.getArticleId().equals("")){
			this.articleService.saveArticle(vo);
			returnMessage = "报名成功！请等待校方电话联系您！";
		}else{
			returnMessage = "报名失败！您已经报过名了！";
		}
	}

	// 预约测试报名
	public void checkOutArticle() {
		returnVo = this.articleService.getArticleVo(vo);
		if(returnVo == null || returnVo.getArticleId().equals("")){
			this.articleService.saveArticle(vo);
			returnMessage = "预约测试报名成功！请等待校方电话联系您！";
		}else{
			returnMessage = "预约测试报名失败！您已经报过名了！";
		}
	}

	// 学生用户注册
	public void registerArticle() {
		returnVo = this.articleService.getArticleVo(vo);
		if(returnVo == null || returnVo.getArticleId().equals("")){
			this.articleService.saveArticle(vo);
		}else{
			this.articleService.saveArticle(returnVo);
		}
		returnMessage = "学生用户注册成功！24小时内核准！请等待";
	}
	// 更新
	public void modifyArticle() {
		this.articleService.saveArticle(vo);
	}

	// 删除
	public void deleteArticle() {
		this.articleService.deleteArticle(deleteId);
	}
}
